(function() {
    angular.module('app').component('tableTopBrandComponent', {
        
        templateUrl: 'app/controllers/industry.controller/table.top.brand.component/table.top.brand.component.html',
        controller: tableTopBrandComponent,
        controllerAs: 'vm',
        bindings: {
            catName: '<'
        }
    });

    tableTopBrandComponent.$inject = ['$scope','tableTopBrandService','util','$rootScope'];

    function tableTopBrandComponent($scope,tableTopBrandService,util,$rootScope){

        var vm = this;

        vm.title = ''; //title标题
        vm.brands = [];

        vm.user = $rootScope.userInfo;

        // console.log(vm.user);

        vm.addMonitor =  tableTopBrandService.addMonitor; //监控
        vm.getBrandDetail = getBrandDetail;

        $scope.$watch('vm.catName',function(newValue,oldValue){
            vm.title = util.catNameFormat(newValue)+"类目品牌排行榜";
            tableTopBrandService.get(newValue).then(function(brands){
                vm.brands = brands;
            });
        });

        function getBrandDetail(brandName){
            $rootScope.$emit('formBrand_detail_EV',brandName);
        }
    }
})();
